Trouble with diff if both buffers empty strings

I have the following code:

for oRow in oTable1 do {
    for oCell in oRow do {
        absNum = oCell."Absolute Number"
        bFound = find(skOldTblObjs, absNum, oOldCell);  //Will return true for this example
        if (bFound) {
            bSource = oOldCell."Object Text";  //empty string ''
            bTarget = oCell."Object Text";     //empty string ''
            setempty(tempBuf);
            setempty(bResult);
            infoBox("bResult: " bResult "")  //Returns 'bResult: '
            diff(bResult, bSource, bTarget);
            infoBox("bResult: " bResult "") //Returns bResult: (long string which includes: {\f1015\fswiss\fcharset 136 Tahoma;})
        }
    }
}

I've made sure that both bSource and bTarget are empty strings.  Instead of giving me an empty string in bResult, I am getting the value of bResult from the previous diff.  Why would it do that?

 

Chris


Christopher Cote - Wed Nov 02 12:22:20 EDT 2016

Re: Trouble with diff if both buffers empty strings
Antonio__Norkus - Wed Nov 02 13:27:23 EDT 2016

The diff result is a rich text string. As such, the result will contain a bunch of rtf formatting information.

So, I don't think you're getting the result of the previous diff. You're getting a rich text string with a load of rtf formatting information, but with zero actual content.

You can observe this by placing the following code in a layout dxl column:
 

Buffer a = create
Buffer b = create
Buffer diffs = create

a = ""
b = ""
string retval = diff(diffs, a, b)
if (retval != "") display "Error: " retval
else displayRich stringOf(diffs)

The displayed rich text string is empty.

Then, change the last line to 

else display stringOf(diffs)

and you'll see the rtf formatting information.

Re: Trouble with diff if both buffers empty strings
DOORSHAM - Wed Nov 02 13:48:20 EDT 2016

You need to set bResult  to empty before performing the if (bFound)

 

If bfound = false then bResult will retain the old value.